/**
 * @(#)Server.java, 2012-2-13. 
 * 
 * Copyright 2012 Yodao, Inc. All rights reserved.
 * YODAO PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.buaaer.rpc;

import java.net.InetSocketAddress;
import java.nio.charset.Charset;

import org.apache.mina.core.service.IoAcceptor;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;

/**
 *
 * @author wangheng
 *
 */
public class Server {
    
    public Server() {
        
    }
    
    public void start() throws Exception {
        
        IoAcceptor ioAcceptor = new NioSocketAcceptor();
        
        ioAcceptor.getFilterChain().addLast("codec",
                new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("UTF-8"))));
        
        ioAcceptor.setHandler(new ServerHandler());
        
        ioAcceptor.bind(new InetSocketAddress(12345));
        
    }
    
    public static void main(String[] args) throws Exception {
        Server server = new Server();
        server.start();
        
    }
    

}
